<?xml version="1.0" ?>
<project xmlns="http://nant.sf.net/release/0.85-rc3/nant.xsd">
	<include buildfile="common.xml" />
	
	<target name="common.compile-tests"
		description="Compile NUnit tests and copy App.config file to the output directory, if it exists.">

		<csc 
			target="library"
			define="${current.build.defines}"
			debug="${build.debug}"
			keyfile="${key.file}"
			output="${bin.dir}/${project::get-name()}.dll"
			if="${sign}">
			<sources refid="project.sources" />
			<references refid="project.references" />
			<resources refid="project.resources" />
		</csc>

		<csc 
			target="library"
			define="${current.build.defines}"
			debug="${build.debug}"
			output="${bin.dir}/${project::get-name()}.dll"
			unless="${sign}">
			<sources refid="project.sources" />
			<references refid="project.references" />
			<resources refid="project.resources" />
		</csc>


		<copy 
			file="App.config"
			tofile="${bin.dir}/${project::get-name()}.dll.config"
			if="${file::exists('App.config')}"/>
	</target>

	<target name="common.compile-dll"	description="Compile sources into a DLL">

		<csc
			target="library" 
			define="${current.build.defines}" 
			debug="${build.debug}" 
			keyfile="${key.file}"
			output="${bin.dir}/${project::get-name()}.dll" 
			doc="${bin.dir}/${project::get-name()}.xml"
			optimize="${build.release}"
			if="${sign}"
		>
			<nowarn>
				<warning number="1591" /> <!-- No XML comment for publicly visible member -->
			</nowarn>
			<sources refid="project.sources" />
			<references refid="project.references" />
			<resources refid="project.resources" />
		</csc>

		<csc
			target="library" 
			define="${current.build.defines}" 
			debug="${build.debug}" 
			output="${bin.dir}/${project::get-name()}.dll" 
			doc="${bin.dir}/${project::get-name()}.xml"
			optimize="${build.release}"
			unless="${sign}"
		>
			<nowarn>
				<warning number="1591" /> <!-- No XML comment for publicly visible member -->
			</nowarn>
			<sources refid="project.sources" />
			<references refid="project.references" />
			<resources refid="project.resources" />
		</csc>

	</target>

	<target name="common.set-assembly-attribute-values">
		<property overwrite="false" name="assembly.is-cls-compliant" value="true" />
		<property overwrite="false" name="assembly.allow-partially-trusted-callers" value="false" />
		<property overwrite="false" name="assembly.description" value="" />
		<property overwrite="false" name="assembly.product" value="${project::get-name()}" />
		<property overwrite="false" name="assembly.company" value="${project.company}" />
		<property overwrite="false" name="assembly.title" value="${project::get-name()}" />
		<property overwrite="false" name="assembly.version" value="${project.version.numeric}" />
		<property overwrite="false" name="assembly.version.informational" value="${project.version.numeric}" />
		<property overwrite="false" name="assembly.version.file" value="${project.version.numeric}" />
		<property overwrite="false" name="assembly.copyright" value="Licensed under LGPL." />
		<property overwrite="false" name="assembly.sign" value="${sign}" />

	</target>

	<target name="common.generate-assemblyinfo"
		depends="common.init common.set-assembly-attribute-values"
		description="Generate AssemblyInfo.cs using assembly.* properties."
	>
		<asminfo output="AssemblyInfo.cs" language="CSharp">
			<imports>
				<import namespace="System" />
				<import namespace="System.Reflection" />
				<import namespace="System.Runtime.CompilerServices" />
				<import namespace="System.Security" if="${assembly.allow-partially-trusted-callers}" />
			</imports>
			<attributes>
				<attribute type="CLSCompliantAttribute" value="${assembly.is-cls-compliant}" />
				<attribute type="AssemblyTitleAttribute" value="${assembly.title}" />
				<attribute type="AssemblyDescriptionAttribute" value="${assembly.description}" />
				<attribute type="AssemblyCompanyAttribute" value="${assembly.company}" />
				<attribute type="AssemblyProductAttribute" value="${assembly.product}" />
				<attribute type="AssemblyCopyrightAttribute" value="${assembly.copyright}" />
				<attribute type="AssemblyVersionAttribute" value="${assembly.version}" />
				<attribute type="AssemblyInformationalVersionAttribute" value="${assembly.version.informational}" />
				<attribute type="AssemblyFileVersionAttribute" value="${assembly.version.file}" />
				<attribute type="AssemblyDelaySignAttribute" value="false" />
				
				<!-- For some reason, NAnt doesn't detect that APTCA has a public no-argument constructor -->
				<attribute asis="true" type="AllowPartiallyTrustedCallersAttribute" if="${assembly.allow-partially-trusted-callers}" />
			</attributes>
		</asminfo>
	</target>

	<target name="common.run-tests"
		description="Run NUnit tests">
		<nunit2>
			<formatter 
				type="Xml" 
				usefile="true" 
				extension=".xml" 
				outputdir="${bin.dir}"
			/>
			<test
				assemblyname="${bin.dir}/${project::get-name()}.dll"
				appconfig="${bin.dir}/${project::get-name()}.dll.config" />
		</nunit2>

	</target>
</project>
